cmake_minimum_required(VERSION 3.14)

project(qgo-articles-client LANGUAGES CXX VERSION 0.0.1)

include(cmake/SparkWithGit.cmake)
spark_initialize_modules()

if(MSVC)
    # MSVC 编译器处理方案，支持 utf-8 编码的项目
    add_compile_options(/utf-8)
endif(MSVC)

# 控制 qDebug 行为
if(CMAKE_BUILD_TYPE MATCHES "Release")
    add_compile_definitions(QT_NO_WARNING_OUTPUT=1 QT_NO_DEBUG_OUTPUT=1)
endif(CMAKE_BUILD_TYPE MATCHES "Release")

# 资源文件路径
set(QRC_SOURCES "resources.qrc")

spark_add_executable_path(${PROJECT_NAME} 
    src
    src/widgets
    src/widgets/override
    src/adapter
    src/utils
    ${QRC_SOURCES}
)
target_link_qt5(${PROJECT_NAME})

# 引入扩展内容
spark_framework_include_with_git(${PROJECT_NAME} 
    https://gitee.com/spark-framework-libs/spark-framework-features
    FEATURES version screenutil eaters)

spark_framework_include_with_git(${PROJECT_NAME}
    https://gitee.com/spark-framework-libs/network-access-libs
    FEATURES httpmanager)

spark_framework_include_with_git(${PROJECT_NAME}
    https://gitee.com/spark-framework-libs/qutils
)

# 在 Windows 中开启 UNICODE 以支持 TCHAR 功能
if(WIN32)
    # Windows 下为目标追加图标资源与目标属性
    add_compile_definitions(_UNICODE= UNICODE=)
    target_sources(${PROJECT_NAME} PRIVATE icon.rc)
    set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE TRUE)
    # include(cmake/windows-deployqt.cmake)
    message("Windows Done.")
    return()
endif(WIN32)

# 准备安装资源
spark_include(SparkDesktopMacros.cmake)
spark_desktop_macros(
    # 应用名称: Name=
    "Article Analyzer"
    # 应用名称: Name[zh_CN]=
    "文章分析工具"
    # 应用说明: Comment=
    ""
    # 应用类型: Type=
    "Application"
    # 执行程序: Exec=
    "${PROJECT_NAME}"
    # 图标路径: Icon=
    "${PROJECT_NAME}"
    # 应用分类: Categories=
    "Utility"
    # MIME类型: MimeType=
    ""
)
install(FILES ${SPARK_DESKTOP_FILE}
    DESTINATION /usr/share/applications
)
install(FILES icon.png
    DESTINATION /usr/share/icons/hicolor/512x512/apps
    RENAME ${PROJECT_NAME}.png
)
install(TARGETS ${PROJECT_NAME}
    DESTINATION bin
)

spark_include(SparkDebPackageConfig.cmake)
add_package_descript(cmake/spark-deb-package.descript)
